package service;

import java.sql.Connection;
import java.sql.SQLException;

import commentControl.Comment;
import commentControl.CommentDao;

import util.mysqlUtil;

public class WriteComment {
	String tableName;
	public WriteComment(String tableName){
		this.tableName = tableName;
	}

	public void write(Comment comment) throws ServiceException {
		Connection conn = null;
		try {
			conn = mysqlUtil.getConn();
			CommentDao commentDao = new CommentDao(tableName);
			commentDao.insert(conn, comment);
		} catch (SQLException e) {
			throw new ServiceException(
					"뎃글 등록 실패: " + e.getMessage(), e);
		} finally {
			mysqlUtil.close(conn);
		}
	}

}
